package com.xucy.springboot.designmodel.structural.Proxy.Dynamic;

import java.lang.reflect.Proxy;

/**
 * @Author xucy
 * @Date 2019-07-28 09:04
 * @Description 动态代理
 *              场景，对插入操作进行事务提交
 **/

public class Test {

    public static void main(String[] args) {
        TargetService targetService=new TargetServiceImpl();
        DynamicProxy dynamicProxy=new DynamicProxy(targetService);

        TargetService proxyService=(TargetService)Proxy.newProxyInstance(targetService.getClass().getClassLoader(),targetService.getClass().getInterfaces(),dynamicProxy);
        proxyService.insert();

        proxyService.delete();
    }
}
